for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
/* eslint-env jest */
import { view, set, over, lensProp } from 'ramda'
import { inGlobalStateLens } from './globalStateLens'
it('Gets the global state', () => {
const tokenLens = lensProp('token')
const globalState = {
store: {
state: { token: 'HET_TOKEN' }
}
const tokenLensInGlobal = inGlobalStateLens(tokenLens)
expect(view(tokenLensInGlobal, globalState)).toBe('HET_TOKEN')
})
it('Sets in the global state', () => {
expect(set(tokenLensInGlobal, 'NEW_TOKEN', globalState)).toStrictEqual({
state: { token: 'NEW_TOKEN' }
it('Runs a function over the lens value in the global state', () => {
expect(
over(tokenLensInGlobal, token => token + token, globalState)
).toStrictEqual({
state: { token: 'HET_TOKENHET_TOKEN' }